import decimal
import json
from decimal import Decimal


class DecimalEncoder(json.JSONEncoder):
    def default(self, o):
        if isinstance(o, decimal.Decimal):
            return float(o)
        super(DecimalEncoder, self).default(o)

def decimal_to_float(res):
    for k, v in res.items():
        if isinstance(v, Decimal):
            res[k] = round(float(v),4)
    return True
